//
//  KYInformationView.m
//  kuaiyi
//
//  Created by 杨亮 on 16/3/13.
//  Copyright © 2016年 kuaiyi. All rights reserved.
//

#import "KYInformationView.h"
#import "KYLoginModel.h"
#import <SDWebImage/UIImageView+WebCache.h>


@interface KYInformationView ()
@property (weak, nonatomic) IBOutlet UIImageView *headImage;
@property (weak, nonatomic) IBOutlet UILabel *userNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *basicInfoLabel;
@property (weak, nonatomic) IBOutlet UIView *topView;

@end

@implementation KYInformationView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor blueColor];
        self = [[[NSBundle mainBundle]loadNibNamed:@"KYInformationView" owner:nil options:0] lastObject];
        [self setUpUI];
    }
    return self;
}
-(void)setUpUI{
    KYLoginModel *loginModel = [KYLoginModel readData];
//    self.headImage.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:loginModel.head_photo]]];
    [self.headImage sd_setImageWithURL:[NSURL URLWithString:loginModel.head_photo]];
    self.headImage.layer.cornerRadius = self.headImage.frame.size.height/2;
    self.headImage.layer.masksToBounds = YES;
    if (loginModel.true_name) {
        self.userNameLabel.text = loginModel.true_name;
    }else{
        self.userNameLabel.text = loginModel.mobile_number;
    }
    UIGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(topViewKlick:)];
    [self.topView addGestureRecognizer:tap];
}
-(void)topViewKlick:(UIGestureRecognizer *)gestureRecognizer{
    [[NSNotificationCenter defaultCenter]postNotificationName:@"topViewKlick" object:nil userInfo:nil];
}
@end
